package com.ludomancy.spaceopera;

import java.awt.Graphics;
import java.awt.Rectangle;
import com.ludomancy.gamelib.Widget;
import com.ludomancy.gamelib.ui.DialogWidget;
import com.ludomancy.gamelib.ui.DialogWidget.DialogListener;

public class MainWidget extends Widget implements DialogListener
{
	public StatusWidget status;
	public SpaceWidget space;
	
	public MainWidget(Widget parent, Rectangle area)
	{
		super(parent, area);
		status = new StatusWidget(this, new Rectangle(getWidth()-60, 0, 60, getHeight()));
		space = new SpaceWidget(this, new Rectangle(0,0,getWidth()-60, getHeight()));
	}
	
	public void paint(Graphics g)
	{
	}
	
//	public static int debugsize = 0;
//	private int debugfont = 0;
//	public void keyPressed(KeyEvent e)
//	{
//		if(e.getKeyCode() == KeyEvent.VK_0)
//		{
//			String[] fonts = new String[]{"computer","computer2","computer3","computer4","computer5","computer6","computer7","computer8","computer9","computer10","computer11","computer12"};
//			debugfont = (debugfont+1) % fonts.length;
//			try
//			{
//				GameTheme.theme.ingame = Utils.loadFont("/"+fonts[debugfont]+".ttf").deriveFont(Font.PLAIN, ++debugsize);
//				System.out.println("font "+fonts[debugfont] +" size "+debugsize);
//			} catch (Exception e1)
//			{
//				// TODO Auto-generated catch block
//				e1.printStackTrace();
//			}
//		}
//
//		if(e.getKeyCode() == KeyEvent.VK_UP)
//		{
//			GameTheme.theme.ingame = GameTheme.theme.ingame.deriveFont(Font.PLAIN, ++debugsize);
//		}
//		if(e.getKeyCode() == KeyEvent.VK_DOWN)
//		{
//			GameTheme.theme.ingame = GameTheme.theme.ingame.deriveFont(Font.PLAIN, --debugsize);
//		}
//		System.out.println("debug "+debugsize);
//	}
	
	public void onMouseExit()
	{
		Game.game.setPaused(true);
	}

	public void onMouseEntered()
	{
		Game.game.setPaused(false);
	}

	public void showGameOver(String msg)
	{
		msg += "\nGame Over";
		StoryWidget story = new StoryWidget(this, new Rectangle(0,0,getWidth(),getHeight()), msg, "Restart", this);
		SpaceOperaApp.app.gameCanvas.showWidgetModal(story);
	}

	public void onDialogClosed(DialogWidget widget)
	{
		SpaceOperaApp.app.resetGame();
	}	
}
